Fixed segfault issue