Fix bug: job is not done if there is any job pending