Added query error checking and complete results table