attempt to fix derivative calculation