nested function so we can simulate a break from outer loops