finally proper memory leak fix