fixed segfault at program end