You should be able to add a break after the inner loop is over.