Maybe move this to an outer `if` and combine the conditional checks