hw4 fixed all memory leaks