fixed major memory leak