Refactroring Matrix