lr almost working, optimisation having problems using matrixes so switched to arrays which is now failing other methods.