Rewrite to class implementation