revised main function