Added capBetween function to CustomMath