fixed javscript bugs