Adjustments to queries and helper functions