better class checking