reorder initialization to fix segfault