nit: this much indentation might make this code a bit hard to read. maybe you can use a separate function for each request?