OOPed

modified procedural code to make it OOP