added flatMap for Either