Cleaning up the main function