Change structure of code for task2.