fix a big memory leak