split steps into individual functions and add cholesky decomposation