added pattern matching