added derivative algo