Refactor helper functions into polyfill scope and omit wide scope usage