Switch from try/except to while count(value) > 0