added validate response function