take global variable to function