Flag was not being reset each time, which could have resulted in it being in an invalid state.