use list_file functions, minor bug fix