refactoring: added util.c and util.h
lsw: refactored to use util.c