Update script to fix a bug and also include non-directories in the listing