Solution for task 1