Refactored, added Prev and Dest page queries

Added the previous and destination page queries

Also refactored the way queries are built

Started work on search quert