Reduce nesting in message loops