factorize code in proxy
Merge pull request #846 from lalebarde/master

factorize code in proxy