inline schedule & moving clearing of task out of batch loop