implemented newton step for vectorized optimisation