HW#6 refactoring