Fix regression from first attempt fixing #5811 (9dce9bddcbbddb252653367f0e39a4c77108f5eb)