Simplify toroidal bounds checking