since we're doing this in several places now we want to factor out this kind of functionality into a distinct module