wrap js into function to set global variables