I would set filename to '' before this conditional, or in a else. If you don't do that, I assume you'll get an undefined warning later in case it's not provided.