refactoring of response processing