if !messages.empty? is preferred