move all rendering out of main