used valgrind and gdb to take away memory leaks and bugs