added flatMap that works with a Result<T>