Fixing KeyError if 'reason' does not exist