Fixed the bug that caused the code to crash in the class