fixed the segfault