Use Result monad where appropriate