move main function to bottom of file