Extracting method to handle response.

@alexmuller, @phss
Trying to clarify logic.

@alexmuller, @phss