added repair function