hw6 refactor