reworked JS

-reworked Code
-added loading indicator