Moves the main function to top.