added new error handling