Use respond_to? instead of checking type

Because it's a generally a bad practice to check the class type