refactored survey query