I cannot figure out better way either. Such replace seems to be a common workaround in such scenarios.