improved message handling