moved few funcs to util.c