Rewrote the algotihm in nateive JS

* Removed jQuery dependency
* optimized for performance