first working version with receiving and sending