Fixed possible buffer overflor problem