Use fabs instead of multiplying by -1.