Deriv function works, but calling it doesn't