Added more exception checks