small changes to main function