change .toPrecision() in if-statements to Number()