refactoring to hw7