Changed type comparison to isinstance