Added in additional error handling