fixed small bug in algorithm for scales