fixed division by zero on scale calculation when max=min