fixed bug in read global var calculation