boiler plate for pattern matching