refactor, change to allow npm publishing