server reset code refactoring