make comparion of loop safe against underflows