Restructured the code in a proper class format.