added null check before GetType is called