solve a memory management bug