Exception handling added