Fixed error in calculating scale.