Algorithm and schedule of reworks