handling memory leaks
finished task2