added break to while loops