fixing the dropdown and rewriting code