use instanceof instead of constructor comparison