Fixing bug in listing directories