Rotate: correct for both large and small inputs