Modularized the caretstate class