trying to solve memory problem