Trying to correctly handle directory index