moved message handling