made pats code more OOP