using flatMap to implement choiceN