corrected query errors unchanged from database rework