refactor global scope parsing into own method