begin pattern recognition