fix issue: we should clear the out buffer before we write new data into it