Cleanup logic
Move query building out of the queryset