Refactored code to be more Object Oriented