moved common functions into function lib dir