fixed the memory bugs' fix