Client: refactoring in main