fixed regex by sorting the words before analysis; also arg values 0 and 1 for word and how many to return