private static int fitToRange(int value, int minValue, int maxValue) {
    return Math.max(minValue, Math.min(value, maxValue));
  }
private static int fitToRange(int value, int minValue, int maxValue)