Improving memory usage ratio algorithm