Advanced tilde substitution