generic response handler