Modularized directory calculation code