Added Exception handling.