implemented memory leaks