need to rewrite native.c and add some help functions in util.c