Why the column of mercury first descends and then rises when a mercury in glass thermometer is put in a flame?

why the column of mercury first descends and then rises when a mercury in glass thermometer is put in a flame