fixed buffer overflow and allow unused bytes to be kept for the next action