First stage of message handling