turned the matrix inverting into a stored procedure