HW9:task2: debugged