removed global variable flag