fix checks in doRepair (use 0 instead of -1)