Added additional error handling to pinpoint issues