Converted the program to OOP