This is an unfortunate level of nesting. Would switching to a more fail-fast approach make this clearer?