Corrected error causing query to fail