split up render in main into separate functions