cleaned up linearization routine
cleaned up linearization routine 3