modulus function now recursive