refactor to real server/client architecture