added derivative function