saving a query to the database, required a little refactoring...not to worry, plenty more where that came from