all code refactored, modular, can be user by cli or as node package