use static variables. still segfaulting