working code on messages