Shuffle this common code around