refactor global eval statement for detection function to be able to be relocated to inner scope.