fixed memory problem