added null check for cwid