Use flatMap to make tests pass