Improves js for dropdowns and moves it to a separate file