Added UnauthorizedException
Added exception check