refactor into a node module