why don't you break from the loop here instead of this extra variable?