repaired function