use global variable rather than pass parameter