using functions to write/read