Fixed type checking to using isinstance