added filter arg for list
added filter arg for list
removed unneeded case
changed format to ensure that the tmp file is removed in all conditions.