Added the maxNumber as a parameter