Add error handling
cleaned error handling