fix unexpected segfault