refactoring code; introducing of named scopes