added generic exception handling