Move main function to the top