fixed possible segfault