refactored scaling example