working code for task 2