first version for matrix calc