cool NOW pattern matching algo works