fix mem leak

major memory leak in the last version