bug fixed: define global vars