fixed a memory bug