Refine methods
Refine set global variables
Merge with Abdullah code