adding random option, and now handling a directory as input with -d option