got the code working, script should function for any square, invertible matrix