refactored for npm