change replace logic