refactor to use one script tag