adding pattern matching code