optimizing clearing