refactored to common
added proxy variables
refactored
refactored
for use in future should server code and client code need to differ