Fix small potential bug with a variable that is used after it goes out of scope

Change-Id: Ica5f05e63bb811141314cc24f4f68be245f364f6