shuffled some code around for more efficient calculations of indexes for numericalitem domains