fixed bug
fixed memory leak