Fix infinite loop bug in subClass