separated js file into various functions, may need to be broken up more in the future