moved functions to main js file