added pattern recognition