code reduction using modulus instead of counters