fixed an issue when returning query results