Add a helper function to reduce a bit of code duplication.