replace function done(but not test yet)