Circular pattern matching