fixing memory problem