improve type assertion in s:expand()