working on typechecking, it compiles but segfaults