first refactor of the program