Probably introduce pattern matching algorithm.