Restructuring to a class