Factor out non-queries