add general pattern matching