trying to fix valgrind errors