Solution to task 3