finalized and debugged server and client