updated the error handling some more