fixed memory leaking problem