version with error handling