Rewrite to OOP