refactored so each element only knows about its children