code reworking to avoid nan in variations for null scale factors