refactoring and comment for server