refactored code on choose