Fixed instanceof check