ported fix from nightscout/cgm-remote-monitor