fixes segfault, need to look into further later..