fix memory bug.  thanks valgrind