Unexpected variable expand behavior