Use instanceof instead of sketchy toString method