improve Task.loop