Added scaling function