fixing possible segfault