refactor to support server integration