rewrite with class