Added changes to add more exception handling