refactoring the program