You need to fashion things in parametric form, so that you are taking the derivatives of x(s) and y(s), and not of y(x).