Factor out choose function