Fix type comparison to use isinstance