refactoring to tackle CloudKit error handling more effectively