Same general comments here about structure of code, variables, early returns, using json.