added support for exceptions and proper returns for them