Almost working version of backend