changed the main function structure