code refactor for server deployment