Using state machine correctly both for sender and receiver