refactoring and modified dir infrastructure