segfault bug eliminated