fixed loop error, wasn't evaluating modulus