refactor LU decomposition