better error handling in JWT fetchtoken