Shouldn't this only replace the first if occurrence? What if there is an if in the condition itself somewhere?