added break points inside loop to reduce unnecessary iterations