Fixed memory leak issue