Yes, this is how I would have don it, but calling the same function over and over again is still code duplication, though unavoidable in this case.