optimizing message handling