variant 3 of hw with oop approach