Changed const to var in Javascript for cross-browser compatibility (IE).