using flatMap to return object