fixed segfault, not every case covered