week6 refactor