adding listeners to process messages based on the state