fixed potential segfault issue