Fix repair logic