Added state information and fixed class attr undefined issue