Refactored scaling_functions.rb