Refactor to support errors and make it robust in the face of exceptions