move comman funcs to libs.go