This deserves a helper function, I think. Not a requirement for this pull request, though.