optimization tricky bit to check mod 6 instead of dividing