Altered the exception handling a little