Fixed error handling
Fixed error handling