restructuring comm.cpp