// some functions for matrix interaction