implementing new method for reducing memory usage but not testet