Refactored the program to fit the first unit test