repair in min function