hw6 refact