move JS code to JS module