reverted global variable implements

added conditions