I've looked this code on ClientService, and it's on processResponse. On ClientService it would be a good idea to move this complex if to a method as well, but this is a different problem. On this class, you could move this if to a method to make the code simpler to read.