This is a fairly common operation, so let's make a utility function for it to cut down on code duplication.