Some exception handling added