Solution to the task2