perform ~ substitution