refactor the handling of the filename arg to make consistent