added optimization to dirdisttool