cleaned up message buffer before write data into it