Wrote the motif finding function