added the breaking condition