Refactored Client and Server