assignment 2 refactoring