fix errors in javascript