corrected instanceof check