refactor template server