finished pattern matching