cleaned up the exception handling and some typos