Task 1 refactoring