Added code for 2nd order derivatives