Fix JavaScript bug