replaced try/catch block with try monad