more optimized derivative