Fixed bug when indexing directory