fix segfault (double free or corruption????)