refactor and add scopes