cleaning up the main function