fixed memory loosing problem