added exception handling.