Configure bridge inside a namespace

I am setting up a topology with 6 namespaces and two of them must be bridges also. My code is like this :

create 6 namespace

sudo ip netns add ns1
sudo ip netns add ns2
sudo ip netns add ns3
sudo ip netns add ns4
sudo ip netns add ns5
sudo ip netns add ns6

creating two bridges

sudo ip link add name br1 type bridge
sudo ip link add name br2 type bridge
sudo ip link set br1 up
sudo ip link set br2 up

for ns in ns1 ns2 ns5 ns6; do

    #configure veth pair
    sudo ip link add $ns-inside1 type veth peer name $ns-outside1

    #add outside half to bridge
    sudo ip link set  dev $ns-outside1 master br1
    sudo ip link set dev $ns-outside1 up

    #add inside half to the namespace
    sudo ip link set  dev $ns-inside1 netns $ns
done

for ns in ns3 ns4 ns5 ns6; do

    #configure veth pair
    sudo ip link add $ns-inside2 type veth peer name $ns-outside2

    #add outside half to bridge
    sudo ip link set  dev $ns-outside2 master br2
    sudo ip link set dev $ns-outside2 up

    #add inside half to the namespace
    sudo ip link set  dev $ns-inside2 netns $ns
 done

I am not able to figure out how to configure br1 and br2 in ns5 and ns6. Please help.