Use isinstance for typechecking