Fixed problem where script was not working with maximum ranges greater than 1000.