fixed a memory management issue