refactor hw3