Fixed check for tasks length