improving the memory usage