started working through valgrind errors