fix logic error in instanceof validation check