Rewrite for scalability