You should check the value of br and bw to make sure they're not null before trying to access them.