modified main function