using instanceof instead of equal check