minor reorganization of the code for future generalization of the client and server sides