Your expectations and your code are doing different things: you coded that you want your maximum be less (-5) than your minimum (-1). That is nonsense and without digging deeper I would guess that this mixup causes your exception.