fixed global variable errors