Replace modulo operator with logical and for speed boost