finalized backend and middleware