Added extra exception checks