simplify loop in close_work