first version of i-matrix
finished i-matrix