Updated scaling routine