072 solution requires refactoring to reduce memory usage