sorted file list, and added exception handling