Fixed the error. Didn't fix the memory leak bug