added some aliases to display tables
added order by clause to sort the array
implemented new algorithm for phrase selection