optimizations to attribute substitution