refactor js into modules