fix bug where extra comma is added sometimes