support nested conditions
only moved function
refactored dom substitutions and conditionals