Replace function fixed