Do not duplicate this code 3×; put it somewhere common.