fixing  potential memory leak