Fixed bug with extra character in javascript