Could this be extracted into a decorator? A couple of other commands have the same logic.