Implement flatMap.