Orientation calculation modified

modulo was being used incorrectly. Corrected.