created some methods to divide the code in afterMessagis()