Adding condition before replacing params