Using Monads for Elegant Error Handling

Refactoring