Factor out task execution