got it to compile, now the only problem is stack overflows