Added try/except for python3 compatibility.