Finalized server-side code