put this at the top of the loop