fixed JavaScript bugs