fixed matrix calculation