Move query to context