Added the backend code to the UI. Still has bugs though. Should fix later