I think refactoring this anymore will impact readability.  The problem is that computing the scale functions needs access to intermediate values.  You'd have to pass a lot of state to make that work.  As is the function is clear and simple, if a bit repetitive.