updated buffer reader and writer helpers