fix the broken `directory listing` function