Got algorithm and backend working