fixed memory usage issue