call function when a script loads.