Refined the dropdown function