move some functions into new util.go