replace type checks with instance checks for objects