Implementation of Memory-efficient method