add buffer to io function