Fixing a bug where classes were appended infinitely