make query more defensively