refactoring js functions on a new file