migrate code from js-algo
typos and fixes
v0.0.2