Improve logic for surround gesture.