move some functions from main.go to hlp.go