beautify javascript and fix a small syntax error