finish functions in util.c