finished backend functionality