Added exception handling.