Further exception handling added