Updated the javascript to be better