refactor this main function, and add eval