using communicate instead of wait