rewrite to OOP