added back global variables accidentally removed