changed to a main javascript function which is inclusive of all other scripts needed