added replace mode