begin work on c version
use static variables. still segfaulting