updated code for class 2