rewrite to classes