matrix thread works now.
teh finished codes.