fixed a memory leaks