fixed segfault in main