Fix potential segfault