Modified code to match OOP practices