Put this section in its own function that returns a json object