implemented chooser and flatMap