modified for lu decomposer