rewrite backend to adapt to new frontend