added survey_query to program and corrected scope