fixed potential segfault