added null check to handler iteration