removed buffer size so the buffer is written without reset
corrected appending bit data