corrected bug on the javascript side