Replaced error checking with try/except.