refactor declare globals