added buildResponse method