fixed JavaScript bug