Some changes in replace method