Refactor js

Rewriting our js to be more readable and less hacky.


Don't need to check for 'selected' just remove