begin refactor for server use