prevent possible segfault correctly