fixed the bad practices in the javascript