added an Object Oriented version of the code