refactor javascript into separate files