limit the other end



Insert another test after the first one.
  if (sa < 0.25) {
    dsa = -dsa;
  }