cleaned up code and prepare for npm publish