refactor and update directory listing route