fix potential memory leak