bug fix for async write and read