segfault fixing