full rewrite to support scaleType