fixing instanceof issue