refactor js into separate files