solution to task2 - refactoring may be needed