Fixed runtime error when the task list is empty