fix memory error, thanks valgrind!