changed the global variable to local variable