support nested expansion and conditional substitution