type scope refactor