Clean try-catch
Use flatMap to make example work and tests pass