Js refactor

Refactored the JS
![](http://replygif.net/i/551.gif)