tidied up main render code a lot. redesigned table format