Improved IO monad's error handling