Updated code. Added class controller