needs to run with valgrind