updated to support errors