Changed the exception function to go inside try/catch curly braces.