In order to make your LU Decomposition algorithm secure partial pivoting must be added.
Pivoting is achieved by ensuring that the diagonal element of the row under consideration is the largest available. This means that before each row operation, the column below is searched and the row containing the largest element is swapped with the current row. A record must be kept of the new permutation so that the RHS elements can be related to the correct rows.