simplified message id checks, updated message ids, made variables local