wrote actual derivative fns