fix bug deleting after replace