js calcul fix and remove space before text on saving