move message update out of conditional block