Changed code to use isinstance in clean method