code rearranging to address bugs related to Serivce/Client communication