added ordering by history and modified the way to access the code for search and qsearch