rewrite using new entity models