finished task4 code.