fixed scope error

* refactored response processing