add function which can transiton cquare matrix