encode reponse correctly