fixed buffer overlow in the case of unused bytes