My pattern finding function - MPGH