fixed buffer overflow bug