Complete matrix transformation, needs improvement