some code cleanup

cleaned up matrix