Fixed JavaScript bug