Refactoring
Refactor getSlidingMinMax