fixed the buffer protection