Made the javascript better