addded more exception handling