trying to refactor according to design. not working