fixed memory leaks using valgrind