fixing a possible memory leak