Use local variable for this.filetype

Because `this` is not guaranteed to be the same
in the callback as the one in the parent closure.
Otherwise this.filetype is undefined.