refactoring according to the hierarchy.