Rewrite using OOP