Made pattern searching opportunistic and dynamic (remembers direction)