improve message handler