added iterator over queryset to solve memory issues