moved some functions to util