moved updatemsgs to outer funct