JavaScript bug fixed