Implemented creation of transition matrix