Fixed scope issue when parsing procedures