inlined a few unctions in util.c