fixing segfault