replacing read/write methods with functions