fix a memory leaks