Error Handling

reapplied error handling