fixing a memory error