add scope and refactor