Fix scale algorithm