minor corrections
added global variables