Updated Newton method to use for loop to avoid some boolean checks