optmize scale math