small stylistic change and optimisation to code from #2847