fix and clean the global scope