add pattern match function