Can this logic be deduplicated with `FunctionValue`?