need to check with valgrind again