Refactoring to use npm modules