fixed buffer 0-termination issue