added template for read and write methods