Fix a bug in setType method