fixed the memory issue