fix and optimize checkSequence with checkMaxAndMin