Rearranged code so some output is printed before tackling the big table