fix problem with ensuring tasks index