Fixed issues with JavaScript