Implemented pattern finding