Code for task 22