Fixed memory leak caused by using new