Fixing segfault