Rewrite backend code