fix all reference to global and put the 2 sub methods to correct place