Abstract out code common to Edit and View