added write/read from buffer