generalize read/write methods