I've added logic to cope with subclasses