added toroid wraparound