checking for messages function