move JS code to outside file