better order
optimize computations
replace a hack with proper attribute value setting