fix potential memleak