refactor for server reuse