move directory storage logic out to a dedicated class