Minor changes to main function