added a minimal typechecker. found a bug!