Refactor the scale function into a multimethod.