fix possible seqmentation fault