Factor out parseResponse