Corrected order of calls in the script tag